Cos

对输入数组逐元素计算余弦值。输入角度单位为弧度。

\[\mathrm{output}_i = \cos(\mathrm{input}_i)\]
输入:
  • input - 输入数据地址

  • length - 计算元素个数

  • core_mask - 核掩码(仅共享存储版本使用)

输出:
  • output - 输出数据地址;i8 / i16 / i32 输入时输出为 float

支持平台:

FT78NE MT7004

备注

  • FT78NE 支持 int8、int16、int32、fp32、fp64

  • MT7004 支持 int16、int32、fp16、fp32

  • 整数输入先转为浮点再计算,结果写为 float

共享存储版本:

void i8_cos_s(int8_t *input, float *output, int length, int core_mask)
void i16_cos_s(int16_t *input, float *output, int length, int core_mask)
void i32_cos_s(int32_t *input, float *output, int length, int core_mask)
void hp_cos_s(float16 *input, float16 *output, int length, int core_mask)
void fp_cos_s(float *input, float *output, int length, int core_mask)
void dp_cos_s(double *input, double *output, int length, int core_mask)

C调用示例:

 1// MT7004 示例(共享存储多核,DDR 地址)
 2void TestCosSMCFp32(int length, int core_mask) {
 3    int core_id = get_core_id();
 4    int logic_core_id = GetLogicCoreId(core_mask, core_id);
 5    int core_num = GetCoreNum(core_mask);
 6    float *input = (float *)0x81000000;
 7    float *output = (float *)0x82000000;
 8    sys_bar(0, core_num);
 9    fp_cos_s(input, output, length, core_mask);
10}
11
12void main() {
13    int core_mask = 0b1111;
14    TestCosSMCFp32(1024, core_mask);
15}

私有存储版本:

void i8_cos_p(int8_t *input, float *output, int length)
void i16_cos_p(int16_t *input, float *output, int length)
void i32_cos_p(int32_t *input, float *output, int length)
void hp_cos_p(float16 *input, float16 *output, int length)
void fp_cos_p(float *input, float *output, int length)
void dp_cos_p(double *input, double *output, int length)

C调用示例:

 1// MT7004 示例(私有存储单核,AM 地址)
 2void TestCosAMFp32(int length) {
 3    float *input = (float *)0x10010000;
 4    float *output = (float *)0x10020000;
 5    fp_cos_p(input, output, length);
 6}
 7
 8void main() {
 9    TestCosAMFp32(1024);
10}